set(tempDir "/tmp/PrintToolChainsCmakeTemp")

file(REMOVE_RECURSE ${tempDir})

file(MAKE_DIRECTORY ${tempDir}/build)
file(COPY ${FILE} DESTINATION ${tempDir})
get_filename_component(FileName "${FILE}" NAME)

configure_file(${CMAKE_ROOT}/Modules/SBE/toolchains/scripts/PrintToolchainSpecForEclipseCMakeLists.txt.in ${tempDir}/CMakeLists.txt @ONLY)

execute_process(
    COMMAND ${CMAKE_COMMAND} -E chdir ${tempDir}/build ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${TYPE} -DCMAKE_TOOLCHAIN_FILE=SBE/toolchains/${TOOLCHAIN} ..
 )
execute_process(
     COMMAND ${CMAKE_COMMAND} -E chdir ${tempDir}/build ${CMAKE_COMMAND} --build . --target PrintSpecs
)

file(REMOVE_RECURSE ${tempDir})